<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titReparticao}" />
	</ui:define>
	<ui:define name="content">
		<p:fieldset id="fieldSetReparticao" legend="#{text.lgdReparticaoForm}"
			toggleable="true" binding="#{reparticaoController.fieldSetReparticao}">
			<h:inputHidden id="reparticaoId" value="#{reparticaoController.selectedReparticao.idReparticao}" />
			<p:messages id="reparticaoMessages" />
			<p:tabView id="tabViewReparticao" widgetVar="tabView">

				<p:tab id="tabReparticao" title="#{text.lblReparticao}">
					<h:panelGrid id="pnlFields" columns="3">
						
						<h:outputLabel for="cod" value="#{text.lblReparticaoCod}" />
						<p:inputText id="cod" required="true" size="15" maxlength="10"
							requiredMessage="#{message.requiredReparticaoDesc}"
							value="#{reparticaoController.selectedReparticao.codReparticao}" />
						<p:message for="cod" />
					
						<h:outputLabel for="desc" value="#{text.lblReparticaoDesc}" />
						<p:inputText id="desc" required="true" size="50" maxlength="40"
							requiredMessage="#{message.requiredReparticaoDesc}"
							value="#{reparticaoController.selectedReparticao.descReparticao}" />
						<p:message for="desc" />

					

						<h:outputLabel for="orgao" value="#{text.lblOrgao}" />
						<h:panelGroup>
							<p:inputText id="orgao" size="50" maxlength="30"
								readonly="true"
								value="#{reparticaoController.selectedReparticao.orgao.descOrgao}"
								styleClass="inputfield-readonly" />
							<p:spacer width="5px" />
							<p:commandButton icon="ui-icon-search" id="selectOrgao"
								update=":frmContent:tabViewReparticao:dlgOrgao" process="@none"
								oncomplete="dlgOrgao.show()" />

							<p:dialog id="dlgOrgao" header="#{text.titDlgOrgao}"
								appendToBody="false" widgetVar="dlgOrgao" modal="false"
								resizable="false" styleClass="dlgSelect" showEffect="drop"
								hideEffect="drop">

								<p:dataTable id="grdOrgao" var="orgao"
									value="#{reparticaoController.orgaoDataModel}"
									widgetVar="grdOrgao" emptyMessage="#{text.grdEmpty}"
									selection="#{reparticaoController.selectedOrgao}"
									paginator="true" rows="10" 
									paginatorAlwaysVisible="false" paginatorPosition="bottom"
									sortBy="#{orgao.descOrgao}"
									paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
									style="width:600px;" filterEvent="enter">
									<p:column selectionMode="single" style="width:18px" />
									<p:column id="colOrgaoNome"
										headerText="#{text.lblOrgao}"
										sortBy="#{orgao.descOrgao}"
										filterBy="#{orgao.descOrgao}">
										<h:outputText value="#{orgao.descOrgao}" />
									</p:column>
									<f:facet name="footer">
										<p:commandButton value="#{text.btnConfirm}"
											oncomplete="dlgOrgao.hide();"
											process=":frmContent:tabViewReparticao:grdOrgao"
											update=":frmContent:tabViewReparticao:orgao"
											actionListener="#{reparticaoController.selectOrgao}" />
										<p:commandButton value="#{text.btnCancel}" global="false"
											onclick="dlgOrgao.hide();" />
									</f:facet>
								</p:dataTable>
							</p:dialog>
						</h:panelGroup>
						<p:message for="orgao" />

						<h:outputLabel for="unidadePagadora"
							value="#{text.lblReparticaoUnidadePagadora}" />
						<p:inputText id="unidadePagadora" size="10" maxlength="5"
							value="#{reparticaoController.selectedReparticao.unidadePagadora}" />
						<p:message for="unidadePagadora" />

						<h:outputLabel for="tipoDisquete"
							value="#{text.lblReparticaoTipoDisquete}" />
						<p:selectOneMenu id="tipoDisquete" effect="fade" style="width:150px;"
							value="#{reparticaoController.selectedReparticao.tipoDiskete}">
							<f:selectItem itemLabel="#{text.lblUnselectCombo}" itemValue="" />
							<f:selectItem itemLabel="#{text.lblComboTipoEnvioSede}" itemValue="0" />
							<f:selectItem itemLabel="#{text.lblComboTipoEnvioFederal}" itemValue="1" />
							<f:selectItem itemLabel="#{text.lblComboTipoEnvioEstadual}" itemValue="2" />
							<f:selectItem itemLabel="#{text.lblComboTipoEnvioMunicipal}" itemValue="3" />
						</p:selectOneMenu>
						<p:message for="tipoDisquete" />

					</h:panelGrid>

				</p:tab>
				<p:tab id="tabContato" title="#{text.lblContato}">
					<h:panelGrid id="pnlContatoFields" columns="3">
						<h:outputLabel for="nomeContato"
							value="#{text.lblReparticaoNomeContato}" />
						<p:inputText id="nomeContato" size="30" maxlength="20"
							value="#{reparticaoController.selectedReparticao.nomeContato}" />
						<p:message for="nomeContato" />

						<h:outputLabel for="ddd" value="#{text.lblReparticaoDDD}" />
						<p:inputMask id="ddd" size="5" maxlength="3"
							value="#{reparticaoController.selectedReparticao.numDdd}" />
						<p:message for="ddd" />

						<h:outputLabel for="phone" value="#{text.lblReparticaoPhone}" />
						<p:inputMask id="phone" size="15" maxlength="10" mask="9999999999"
							value="#{reparticaoController.selectedReparticao.numTelefone}" />
						<p:message for="phone" />

						<h:outputLabel for="fax" value="#{text.lblReparticaoFax}" />
						<p:inputMask id="fax" size="15" maxlength="10" mask="9999999999"
							value="#{reparticaoController.selectedReparticao.numFax}" />
						<p:message for="fax" />

						<h:outputLabel for="email" value="#{text.lblReparticaoEmail}" />
						<p:inputText id="email" size="70" maxlength="100"
							mask="9999999999"
							value="#{reparticaoController.selectedReparticao.email}"
							validatorMessage="#{message.invalidEmail}">
							<f:validator validatorId="emailValidate" />
						</p:inputText>
						<p:message for="email" />
					</h:panelGrid>
				</p:tab>
				<p:tab id="tabEndereco" title="#{text.lblEndereco}">
					<h:panelGrid id="pnlEndereco" columns="3">
						<h:outputLabel for="endLogra" value="#{text.lblEnderecoLogra}" />
						<p:inputText id="endLogra" size="65" maxlength="45"
							value="#{reparticaoController.selectedReparticao.endLogra}" />
						<p:message for="endLogra" />

						<h:outputLabel for="endNumero" value="#{text.lblEnderecoNumero}" />
						<p:inputText id="endNumero" size="10" maxlength="10"
							value="#{reparticaoController.selectedReparticao.endNumero}" />
						<p:message for="endNumero" />

						<h:outputLabel for="endComplemento"
							value="#{text.lblEnderecoComp}" />
						<p:inputText id="endComplemento" size="40" maxlength="20"
							value="#{reparticaoController.selectedReparticao.endCompl}" />
						<p:message for="endComplemento" />

						<h:outputLabel for="endBairro" value="#{text.lblEnderecoBairro}" />
						<p:inputText id="endBairro" size="40" maxlength="20"
							value="#{reparticaoController.selectedReparticao.endBairro}" />
						<p:message for="endBairro" />

						<h:outputLabel for="endCidade" value="#{text.lblEnderecoCidade}" />
						<p:inputText id="endCidade" size="40" maxlength="20"
							value="#{reparticaoController.selectedReparticao.endCidade}" />
						<p:message for="endCidade" />


						<h:outputLabel for="endUF" value="#{text.lblUF}" />
						<p:selectOneMenu id="endUF"
							value="#{reparticaoController.selectedReparticao.uf.id}"
							effect="fade" style="width:100px;">
							<f:selectItem itemLabel="#{text.lblUnselectCombo}" itemValue="" />
							<f:selectItems value="#{reparticaoController.ufList}"
								var="estado" itemLabel="#{estado.siglaUf}"
								itemValue="#{estado.idUf}" />
						</p:selectOneMenu>
						<p:message for="endUF" />

						<h:outputLabel for="endCEP" value="#{text.lblEnderecoCEP}" />
						<p:inputMask id="endCEP" size="15" maxlength="8" mask="99999999"
							value="#{reparticaoController.selectedReparticao.endCep}" />
						<p:message for="endCEP" />
					</h:panelGrid>

				</p:tab>
			</p:tabView>

			<p:separator />

	
			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk"
				update=":frmContent:fieldSetReparticao"
				actionListener="#{reparticaoController.saveReparticao}"
				process=":frmContent:fieldSetReparticao"
				oncomplete="handleComplete(xhr, status, args)" />
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{reparticaoController.btnDelete}" disabled="#{sessionScope.idReparticao == null}"
				global="false" />
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					action="#{reparticaoController.deleteReparticao}"
					immediate="true"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide(),tabView.select(0);handleComplete(xhr, status, args);"
					/>
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" global="false" />
			</p:confirmDialog>
			
			<p:button id="btnBackBotton" value="#{text.btnBack}"
				outcome="/pages/reparticao/list.xhtml?selectedMenu=0" ajax="false" async="false"
				icon="ui-icon-arrowreturnthick-1-w" />

		</p:fieldset>


		<script type="text/javascript">
			function handleComplete(xhr, status, args) {
				if (!args.validationFailed) {
					$(PrimeFaces.escapeClientId("frmContent:reparticaoMessages"))
							.remove();
				}
			}
		</script>



	</ui:define>
</ui:composition>
</html>